package com.zxjbyte.yiyi.module.upms.messaging.eventbus.publisher;

import com.zxjbyte.yiyi.framework.common.enums.EventTypeEnum;
import com.zxjbyte.yiyi.framework.common.util.EventBusUtil;
import com.zxjbyte.yiyi.module.upms.domain.entity.UserPO;
import com.zxjbyte.yiyi.module.upms.messaging.eventbus.event.UserEvent;
import org.springframework.stereotype.Component;

/**
 * 用户事件发布器
 *
 * @Author zhangxingjia
 * @Date 2025/3/28 19:41
 * @Version: 1.0
 */
@Component
public class UserEventPublisher {

    /**
     * 发布用户创建事件
     * @param user 创建的用户对象
     */
    public void publishUserCreateEvent(UserPO user) {
        EventBusUtil.asyncPublishEvent(UserEvent.of(user, EventTypeEnum.CREATE));
    }

    /**
     * 发布用户更新事件
     * @param user 更新的用户对象
     */
    public void publishUserUpdateEvent(UserPO user) {
        EventBusUtil.asyncPublishEvent(UserEvent.of(user, EventTypeEnum.UPDATE));
    }
}
